package test.nodes;

import bgai.ai.minimax.BoardType;
import bgai.ai.minimax.Search;

public class MyMain {
	
	public static void main(String [] args) {
		Node root= creaAlbero03();
		MyEval eval= new MyEval();
		
		//Search.bestMoveStar(eval, root, 10);
		Search.bestMoveStar(eval, root, 10, -5, +5);
		//Search.bestMoveExpectimax(eval, root, 10);
	}
	
	private static Node creaAlbero03() {

		Node root;
		Node node2, node3, node4, n2;
		
		// radice
		root= new Node("1", BoardType.MAX);
		
		// livello 1
		node2= new Node("2", BoardType.CHANCE);
		node3= new Node("3", BoardType.CHANCE);
		node4= new Node("4", BoardType.CHANCE);
		root.add(node2);
		root.add(node3);
		root.add(node4);
		
		// livello 2
		
		// nodo 2
		n2= new Node("5", BoardType.MIN);
		n2.add(new Node("12", -10, BoardType.CHANCE));
		n2.add(new Node("13", 5, BoardType.CHANCE));
		n2.add(new Node("14", -4, BoardType.CHANCE));
		node2.add(n2);
		n2= new Node("6", BoardType.MIN);
		n2.add(new Node("15", -3, BoardType.CHANCE));
		n2.add(new Node("16", -4, BoardType.CHANCE));
		node2.add(n2);
		
		// nodo 3
		n2= new Node("7", BoardType.MIN);
		n2.add(new Node("17", 10, BoardType.CHANCE));
		n2.add(new Node("18", 6, BoardType.CHANCE));
		n2.add(new Node("19", 1, BoardType.CHANCE));
		node3.add(n2);
		n2= new Node("8", BoardType.MIN);
		n2.add(new Node("20", 2, BoardType.CHANCE));
		n2.add(new Node("21", -2, BoardType.CHANCE));
		node3.add(n2);
		n2= new Node("9", BoardType.MIN);
		n2.add(new Node("22", 4, BoardType.CHANCE));
		n2.add(new Node("23", -6, BoardType.CHANCE));
		n2.add(new Node("24", -10, BoardType.CHANCE));
		node3.add(n2);
		
		// nodo 4
		n2= new Node("10", BoardType.MIN);
		n2.add(new Node("25", 1, BoardType.CHANCE));
		n2.add(new Node("26", 2, BoardType.CHANCE));
		n2.add(new Node("27", 3, BoardType.CHANCE));
		node4.add(n2);
		n2= new Node("11", BoardType.MIN);
		n2.add(new Node("28", -1, BoardType.CHANCE));
		n2.add(new Node("29", -6, BoardType.CHANCE));
		n2.add(new Node("30", -10, BoardType.CHANCE));
		node4.add(n2);
		
		return root;
	}
	
	private static Node creaAlbero02() {
		Node root;
		Node nodeA, n2;
		
		// radice
		root= new Node("R", BoardType.MAX);
		
		// livello 1
		nodeA= new Node("A", BoardType.CHANCE);
		root.add(nodeA);
		
		// livello 2
		
		// nodo B
		n2= new Node("B", BoardType.MIN);
		n2.add(new Node("D", 4, BoardType.CHANCE)); // D
		n2.add(new Node("E", 6, BoardType.CHANCE)); // E 
		nodeA.add(n2);
		
		// nodo C
		n2= new Node("C", BoardType.MIN);
		n2.add(new Node("F", 5, BoardType.CHANCE)); // F
		n2.add(new Node("G", 3, BoardType.CHANCE)); // G
		nodeA.add(n2);
		
		
		return root;
	}
	
	private static Node creaAlbero01() {
		Node root;
		Node nodeA, n2;
		
		// radice
		root= new Node("R", BoardType.MAX);
		
		// livello 1
		nodeA= new Node("A", BoardType.CHANCE);
		root.add(nodeA);
		
		// livello 2
		
		// nodo B
		n2= new Node("B", BoardType.MIN);
		n2.add(new Node("H", -5, BoardType.CHANCE)); // H
		n2.add(new Node("I", 5, BoardType.CHANCE)); // I
		nodeA.add(n2);
		
		// nodo C
		n2= new Node("C", BoardType.MIN);
		n2.add(new Node("J", -10, BoardType.CHANCE)); // J
		n2.add(new Node("K", -9, BoardType.CHANCE)); // K
		nodeA.add(n2);
		
		// nodo D
		n2= new Node("D", BoardType.MIN);
		n2.add(new Node("L", 0, BoardType.CHANCE)); // L
		n2.add(new Node("M", 5, BoardType.CHANCE)); // M
		nodeA.add(n2);
		
		// nodo E
		n2= new Node("E", BoardType.MIN);
		n2.add(new Node("N", 1, BoardType.CHANCE)); // N
		n2.add(new Node("O", 3, BoardType.CHANCE)); // O
		nodeA.add(n2);

		// nodo F
		n2= new Node("F", BoardType.MIN);
		n2.add(new Node("P", -10, BoardType.CHANCE)); // P
		n2.add(new Node("Q", -1, BoardType.CHANCE)); // Q
		n2.add(new Node("R", 2, BoardType.CHANCE)); // R
		nodeA.add(n2);
		
		// nodo G
		n2= new Node("G", BoardType.MIN);
		n2.add(new Node("S", 5, BoardType.CHANCE)); // S
		n2.add(new Node("T", 4, BoardType.CHANCE)); // T
		n2.add(new Node("U", 3, BoardType.CHANCE)); // U
		nodeA.add(n2);
		
		return root;
		
	}
}
